<?php   if(!defined('DEDEINC')) exit("Request Error!");

/**
 * 用户中心首页我的动态模板mypmslist标签
 *
 */
function plus_mypmslist(&$atts,&$refObj,&$fields)
{
    global $dsql,$cfg_ml,$cfg_memberurl,$cfg_cmsurl;

    $attlist = "titlelen=30,infolen=200,row=6";
    FillAtts($atts,$attlist);
    FillFields($atts,$fields,$refObj);
    extract($atts, EXTR_OVERWRITE);
    $mid = $mid;
	
	$wsql = "h.toid='".$cfg_ml->M_ID."' AND h.folder='inbox' AND h.writetime > 0";
    $query = "SELECT h.* FROM `#@__member_pms` h WHERE $wsql ORDER BY sendtime DESC LIMIT 0,$row";

    $dsql->SetQuery($query);
    $dsql->Execute("al");
    $rearr = array();
    while($row = $dsql->GetArray("al"))
    {
		if($row['hasview']==0){
			$row['hasview'] = "<a href='".$cfg_memberurl."/pm.php?dopost=read&id=".$row['id']."' target='_blank'>查看 <font color=red>未读</font></a>";
		}else{
			$row['hasview'] = "<a href='".$cfg_memberurl."/pm.php?dopost=read&id=".$row['id']."' target='_blank'>查看</a>";
		}
        $row['arcurl'] = $cfg_memberurl."/pm.php?dopost=read&id=".$row['id'];
		$row['sendtime']= FloorTime(time()- $row['sendtime']);
        $rearr[] = $row;
    }
    $dsql->FreeResult("al");
    return $rearr;
}